package com.huawei.appmarket.service.installfail;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.hms.framework.network.restclient.hianalytics.HianalyticsData;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import o.azb;
import o.cdb;
import o.cdg;
import o.ced;
import o.cef;
import o.cks;
import o.cku;
import o.cnw;
import o.coc;
import o.coe;
import o.dgm;
import o.Logger;
import o.dsl;
import o.dwq;
import o.eao;
import o.eap;
import o.emz;
import o.epq.d;
import o.erw;
import o.etn;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;
import o.fho;
import o.fhz;
import o.ll;

public class InstallFailDescriptionFragment extends TaskFragment<InsFailFragmentProtocol> {
    private TextView ʹ;
    private Button ʻˊ;
    private TextView ʻˋ;
    private TextView ʻᐝ;
    private String ʼ = "";
    private ImageView ʼˊ;
    private TextView ʼˋ;
    private Button ʼᐝ;
    private View ʽ = null;
    private View ʽˊ;
    private View ʽˋ;
    private View ʽᐝ;
    private ProgressBar ʾॱ;
    private c ʿॱ;
    private View ˈॱ;
    private String ˊ = "";
    private final BroadcastReceiver ˊʻ = new SafeBroadcastReceiver(this) {
        final /* synthetic */ InstallFailDescriptionFragment ˎ;

        {
            this.ˎ = r1;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            int i = 0;
            String action = intent.getAction();
            if ("android.intent.action.PACKAGE_ADDED".equals(action)) {
                if (this.ˎ.ॱˋ() != null && !this.ˎ.ॱˋ().isFinishing()) {
                    this.ˎ.ʽˊ();
                    this.ˎ.ॱˋ().finish();
                }
            } else if ("com.huawei.appmarket.support.pm.PackageViewStatusManager.message.change".equals(action) && this.ˎ.ॱˋ() != null && !this.ˎ.ॱˋ().isFinishing()) {
                int intExtra = intent.getIntExtra(HianalyticsData.ERROR_CODE, 0);
                Object stringExtra = intent.getStringExtra("icon_url");
                Object stringExtra2 = intent.getStringExtra("app_name");
                String stringExtra3 = intent.getStringExtra("pkgName");
                String stringExtra4 = intent.getStringExtra("conflicting_pkg");
                String stringExtra5 = intent.getStringExtra("conflicting_app_name");
                if (intExtra == 0 || TextUtils.isEmpty(stringExtra) || TextUtils.isEmpty(stringExtra2) || TextUtils.isEmpty(stringExtra3)) {
                    i = 1;
                }
                if (i != 0) {
                    this.ˎ.ʽˊ();
                    return;
                }
                this.ˎ.ˋ = intExtra;
                this.ˎ.ॱ = stringExtra;
                this.ˎ.ˊ = stringExtra2;
                this.ˎ.ˏ = stringExtra3;
                this.ˎ.ᐝ = stringExtra4;
                this.ˎ.ʼ = stringExtra5;
                this.ˎ.ʽᐝ();
                this.ˎ.ʽˊ();
            }
        }
    };
    private int ˋ = 0;
    private final eap ˎ = eap.ˎ();
    private String ˏ = "";
    private String ॱ = "";
    private TextView ॱॱ;
    private String ᐝ = "";
    private TextView ﹳ;
    private TextView ﾞ;
    private TextView ﾟ;

    static class a implements OnClickListener {
        private final InstallFailDescriptionFragment ˋ;

        public a(InstallFailDescriptionFragment installFailDescriptionFragment) {
            this.ˋ = installFailDescriptionFragment;
        }

        public void onClick(View view) {
            cku ˏ = cku.ˏ(this.ˋ.ॱˋ(), cku.class, this.ˋ.ॱ(n.ⴾ), this.ˋ.ॱ(n.ⁱॱ));
            ˏ.ॱ(-1, this.ˋ.ॱ(n.ᶥˊ));
            ˏ.ॱ(-2, this.ˋ.ॱ(n.ᵔ));
            ˏ.setCancelable(false);
            ˏ.ॱ(new cks(this) {
                final /* synthetic */ a ˋ;

                {
                    this.ˋ = r1;
                }

                public void enableNetworking() {
                    this.ˋ.ˋ.ʾॱ();
                    eao o_eao = new eao();
                    o_eao.ॱ(this.ˋ.ˋ.ˋ);
                    o_eao.ॱ(this.ˋ.ˋ.ˊ);
                    o_eao.ˏ(this.ˋ.ˋ.ॱ);
                    o_eao.ˊ(this.ˋ.ˋ.ˏ);
                    eap.ॱ(o_eao);
                    this.ˋ.ˋ.ˈॱ();
                }

                public void upgrade() {
                    this.ˋ.ˋ.ॱˋ().finish();
                }

                public void ˋ() {
                }
            });
            ˏ.ˎ(this.ˋ.ॱˋ());
        }
    }

    static class b implements OnClickListener {
        private final InstallFailDescriptionFragment ˋ;

        public b(InstallFailDescriptionFragment installFailDescriptionFragment) {
            this.ˋ = installFailDescriptionFragment;
        }

        public void onClick(View view) {
            ॱ();
        }

        private void ॱ() {
            Context ॱˋ = this.ˋ.ॱˋ();
            emz.ॱ(ॱˋ, "internal_webview", d.ˊ(dgm.ˎ(ॱˋ), ॱˋ));
        }
    }

    class c {
        final /* synthetic */ InstallFailDescriptionFragment ˋ;

        private c(InstallFailDescriptionFragment installFailDescriptionFragment) {
            this.ˋ = installFailDescriptionFragment;
        }

        private void ˋ() {
            if (this.ˋ.ˎ.ˎ(this.ˋ.ˋ)) {
                this.ˋ.ʻˊ.setText(this.ˋ.ॱˋ().getString(n.ᵔ));
                this.ˋ.ʼᐝ.setText(this.ˋ.ॱˋ().getString(n.ᶥˋ));
                this.ˋ.ʼᐝ.setOnClickListener(new b(this.ˋ));
            } else if (this.ˋ.ˎ.ˋ(this.ˋ.ˋ)) {
                this.ˋ.ʻˊ.setText(this.ˋ.ॱˋ().getString(n.ˍ));
                this.ˋ.ʼᐝ.setText(this.ˋ.ॱˋ().getString(n.ᶥˋ));
                if (erw.ˊ(this.ˋ.ॱˋ(), this.ˋ.ˏ)) {
                    this.ˋ.ﾟ.setText(this.ˋ.ॱˋ().getString(n.ᶥᐝ));
                } else {
                    this.ˋ.ﾟ.setText(this.ˋ.ॱˋ().getString(n.ᶡ));
                }
                this.ˋ.ʼᐝ.setOnClickListener(new b(this.ˋ));
            } else {
                this.ˋ.ʿॱ();
            }
        }

        private void ˊ(eao o_eao) {
            int ˋ = ((cdg) cdb.ॱ(cdg.class)).ˋ(o_eao.ॱ());
            if (ˋ == 2 || ˋ == 1) {
                dsl.ˊ(o_eao.ॱ(), o_eao.ˎ(), o_eao.ˏ(), 0, coc.ˎ);
                eap.ˎ(this.ˋ.ˏ, this.ˋ.ˋ);
                return;
            }
            Logger.ˋ("InstallFailFragment", o_eao.ॱ() + " file can not find.");
            new Handler().postDelayed(new Runnable(this) {
                final /* synthetic */ c ˏ;

                {
                    this.ˏ = r1;
                }

                public void run() {
                    this.ˏ.ˋ.ʽˊ();
                }
            }, 500);
        }
    }

    static class e implements OnClickListener {
        private final InstallFailDescriptionFragment ˏ;

        public e(InstallFailDescriptionFragment installFailDescriptionFragment) {
            this.ˏ = installFailDescriptionFragment;
        }

        public void onClick(View view) {
            ced.ˋ(this.ˏ.ॱˋ(), "com.huawei.systemmanager", null, cef.ˎ("com.huawei.systemmanager"));
            final cku ˏ = cku.ˏ(this.ˏ.ॱˋ(), cku.class, this.ˏ.ॱ(n.ᶥˊ), this.ˏ.ॱ(n.ᶦ));
            ˏ.ॱ(-1, this.ˏ.ॱ(n.ᶥˊ));
            ˏ.ॱ(-2, this.ˏ.ॱ(n.ᵔ));
            ˏ.setCancelable(false);
            ˏ.ॱ(new cks(this) {
                final /* synthetic */ e ॱ;

                {
                    this.ॱ = r1;
                }

                public void enableNetworking() {
                    this.ॱ.ˏ.ʾॱ();
                    eao o_eao = new eao();
                    o_eao.ॱ(this.ॱ.ˏ.ˊ);
                    o_eao.ˏ(this.ॱ.ˏ.ॱ);
                    o_eao.ˊ(this.ॱ.ˏ.ˏ);
                    this.ॱ.ˏ.ʿॱ.ˊ(o_eao);
                }

                public void upgrade() {
                    this.ॱ.ˏ.ॱˋ().finish();
                }

                public void ˋ() {
                }
            });
            new Handler().postDelayed(new Runnable(this) {
                final /* synthetic */ e ˋ;

                public void run() {
                    ˏ.ॱ(this.ˋ.ˏ.ॱˋ(), "installnospace");
                }
            }, 1000);
        }
    }

    public void ˏ(Bundle bundle) {
        super.ˏ(bundle);
        this.ʿॱ = new c();
        this.ˋ = ((InsFailFragmentProtocol) ˆ()).ˏ().ॱ();
        this.ॱ = ((InsFailFragmentProtocol) ˆ()).ˏ().ˎ();
        this.ˊ = ((InsFailFragmentProtocol) ˆ()).ˏ().ˊ();
        this.ˏ = ((InsFailFragmentProtocol) ˆ()).ˏ().ˋ();
        this.ᐝ = ((InsFailFragmentProtocol) ˆ()).ˏ().ˏ();
        this.ʼ = ((InsFailFragmentProtocol) ˆ()).ˏ().ʼ();
        ʼᐝ();
    }

    private void ʼᐝ() {
        try {
            IntentFilter intentFilter = new IntentFilter();
            intentFilter.addAction("com.huawei.appmarket.support.pm.PackageViewStatusManager.message.change");
            ll.ˏ(ॱˋ()).ˏ(this.ˊʻ, intentFilter);
            intentFilter = new IntentFilter();
            intentFilter.addAction("android.intent.action.PACKAGE_ADDED");
            intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");
            intentFilter.addDataScheme(HiAnalyticsConstant.BI_KEY_PACKAGE);
            ॱˋ().registerReceiver(this.ˊʻ, intentFilter);
        } catch (Throwable e) {
            Logger.ˋ("InstallFailFragment", "registerReceiver() ", e);
        }
    }

    public void ˎˎ() {
        super.ˎˎ();
        try {
            ll.ˏ(ॱˋ()).ˋ(this.ˊʻ);
            ॱˋ().unregisterReceiver(this.ˊʻ);
        } catch (Throwable e) {
            Logger.ˋ("InstallFailFragment", "unregisterReceiver ", e);
        }
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        ˎ(layoutInflater, viewGroup);
        ʽᐝ();
        return this.ʽ;
    }

    private void ˎ(LayoutInflater layoutInflater, ViewGroup viewGroup) {
        this.ʽ = layoutInflater.inflate(h.ॱﹳ, viewGroup, false);
        this.ʻˊ = (Button) this.ʽ.findViewById(j.ᴵˊ);
        this.ʼᐝ = (Button) this.ʽ.findViewById(j.ꜟॱ);
        this.ॱॱ = (TextView) this.ʽ.findViewById(j.ॱʼ);
        this.ʹ = (TextView) this.ʽ.findViewById(j.ꜞᐝ);
        this.ﾟ = (TextView) this.ʽ.findViewById(j.ꓸᐝ);
        this.ﹳ = (TextView) this.ʽ.findViewById(j.ॱˎ);
        this.ﾞ = (TextView) this.ʽ.findViewById(j.ॱᐝ);
        this.ʻᐝ = (TextView) this.ʽ.findViewById(j.ʻॱ);
        this.ʼˋ = (TextView) this.ʽ.findViewById(j.ʾ);
        this.ʼˊ = (ImageView) this.ʽ.findViewById(j.ˏˎ);
        this.ʻˋ = (TextView) this.ʽ.findViewById(j.ᐝॱ);
        this.ʾॱ = (ProgressBar) this.ʽ.findViewById(j.ߵˊ);
        this.ʽˊ = this.ʽ.findViewById(j.ߺˏ);
        this.ʽˊ.setBackgroundColor(this.ʽ.getContext().getResources().getColor(o.ewm.c.ॱˎ));
        this.ʽᐝ = this.ʽ.findViewById(j.ˈˑ);
        this.ʽˋ = this.ʽ.findViewById(j.ᐝʼ);
        this.ˈॱ = this.ʽ.findViewById(j.ʻꜝ);
        ॱ();
    }

    public void ॱ() {
        LayoutParams layoutParams = (LayoutParams) this.ʽᐝ.getLayoutParams();
        layoutParams.height = (azb.ॱ(ॱˋ()) * 9) / 16;
        this.ʽᐝ.setLayoutParams(layoutParams);
    }

    private void ʾॱ() {
        if (ॱˋ() != null && !ॱˋ().isFinishing()) {
            if (this.ʽˊ != null) {
                this.ʽˊ.setVisibility(0);
            }
            if (this.ʾॱ != null) {
                this.ʾॱ.setVisibility(0);
            }
            if (this.ʽᐝ != null) {
                this.ʽᐝ.setVisibility(8);
            }
            if (this.ʽˋ != null) {
                this.ʽˋ.setVisibility(8);
            }
            if (this.ˈॱ != null) {
                this.ˈॱ.setVisibility(8);
            }
        }
    }

    private void ʽˊ() {
        if (ॱˋ() != null && !ॱˋ().isFinishing()) {
            if (this.ʾॱ != null) {
                this.ʾॱ.setVisibility(8);
            }
            if (this.ʽˊ != null) {
                this.ʽˊ.setVisibility(8);
            }
            if (this.ʽᐝ != null) {
                this.ʽᐝ.setVisibility(0);
            }
            if (this.ʽˋ != null) {
                this.ʽˋ.setVisibility(0);
            }
            if (this.ˈॱ != null) {
                this.ˈॱ.setVisibility(0);
            }
        }
    }

    private void ʽᐝ() {
        CharSequence ˏ;
        this.ॱॱ.setText(this.ˊ);
        this.ʹ.setText(this.ˎ.ˋ(this.ˋ, ॱˋ()));
        String str = "";
        if (this.ˋ == -13 || this.ˋ == -112) {
            ˏ = this.ˎ.ˏ(this.ˋ, ॱˋ(), new Object[]{this.ʼ});
        } else {
            ˏ = this.ˎ.ˎ(this.ˋ, ॱˋ());
        }
        this.ﾟ.setText(ˏ);
        this.ʻˊ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ InstallFailDescriptionFragment ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.ॱˋ().finish();
            }
        });
        Integer ˏ2 = eap.ˏ(this.ˏ);
        if (ˏ2 == null || ˏ2.intValue() != this.ˋ) {
            ʿॱ();
        } else {
            this.ʿॱ.ˋ();
        }
    }

    private void ʿॱ() {
        String[] strArr;
        if (this.ˋ == -112 || this.ˋ == -13) {
            strArr = new String[2];
            strArr[0] = ˎ(n.ꜞˊ, new Object[]{Integer.valueOf(1), this.ʼ});
            strArr[1] = ˎ(n.ॱߵ, new Object[]{Integer.valueOf(2)});
        } else {
            strArr = this.ˎ.ॱ(ॱˋ(), this.ˋ);
        }
        ˋ(strArr);
        strArr = this.ˎ.ॱ(this.ˋ, ॱˋ());
        if (strArr == null || strArr.length != 2) {
            this.ʼᐝ.setOnClickListener(new b(this));
            return;
        }
        this.ʻˊ.setText(strArr[0]);
        this.ʼᐝ.setText(strArr[1]);
        if (this.ˎ.ˎ(this.ˋ) || this.ˎ.ˏ(this.ˋ)) {
            this.ʼᐝ.setOnClickListener(new b(this));
        } else if (this.ˎ.ˋ(this.ˋ)) {
            this.ﾟ.setText(n.ₗ);
            this.ʼᐝ.setOnClickListener(new a(this));
        } else if (this.ˎ.ˊ(this.ˋ)) {
            this.ﾟ.setText(n.ᶫॱ);
            this.ʼᐝ.setOnClickListener(new e(this));
        } else {
            this.ʼᐝ.setOnClickListener(new b(this));
        }
    }

    private void ˋ(String[] strArr) {
        if (strArr == null || strArr.length <= 0) {
            this.ʼˋ.setVisibility(8);
            this.ﹳ.setVisibility(8);
            this.ﾞ.setVisibility(8);
            this.ʻᐝ.setVisibility(8);
            this.ʻˋ.setVisibility(8);
        } else if (strArr.length >= 2) {
            this.ʼˋ.setVisibility(0);
            this.ﹳ.setText(strArr[0]);
            this.ﹳ.setVisibility(0);
            this.ﾞ.setText(strArr[1]);
            this.ﾞ.setVisibility(0);
            if (strArr.length == 3) {
                this.ʻᐝ.setText(strArr[2]);
                this.ʻᐝ.setVisibility(0);
            }
            if (strArr.length == 4) {
                this.ʻᐝ.setText(strArr[2]);
                this.ʻᐝ.setVisibility(0);
                this.ʻˋ.setText(strArr[3]);
                this.ʻˋ.setVisibility(0);
            }
        }
    }

    private void ˈॱ() {
        int ˊ = etn.ˊ(0);
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            cnw o_cnw = (cnw) ˋ.ॱ(cnw.class);
            if (o_cnw != null) {
                o_cnw.ˋ(ॱˊ(), new o.col.e().ॱ(this.ˏ).ˏ(ˊ).ॱ(new coe(this.ˊ)).ˋ(coc.ˏ).ˏ(dwq.ˊ).ॱ());
                return;
            }
            Logger.e("InstallFailFragment", "can not found IPackageInstaller Api");
            return;
        }
        Logger.e("InstallFailFragment", "can not found PackageManager module");
    }
}
